package Q2;

import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String str = scanner.next();
        int len = str.length();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < len; i++) {
            map.put(str.charAt(i), map.getOrDefault(str.charAt(i), 0) + 1);
        }

        //对 map 的 value 降序排序
        List<Integer> collect = map.values()
                                    .stream()
                                    .sorted(Comparator.reverseOrder())
                                    .collect(Collectors.toList());

        if (collect.size() == 1) {
            System.out.println(collect.get(0));
        } else {
            System.out.println(collect.get(0) + collect.get(1));
        }
    }
}
